// var _value='username='+document.getElementsByClassName("username")+'&password='+document.getElementsByClassName("password");

// console.log(JSON.parse(_value));
function send_first(){
  let username=document.getElementsByClassName("username")[0].value;
let password=document.getElementsByClassName("password")[0].value;
let _value=`username=${username}&password=${password}`; 
console.log(_value);
    $ajax({
    method: "post",
    url: "http://qlapi.sylu.edu.cn/mock/67/login",
   // data: '${_value}',
    data: _value,
    success:function (res){
        console.log(res);
        alert("登录成功");
      },
      error:function(err){
        console.log(err);
      },
      });} 
       
    function $ajax({ method , url, data, success, error }) {
        var xhr = null;
        try {
          xhr = new XMLHttpRequest();
        } catch (error) {
          xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (method == "get" && data) {
          url += `?${data}`;
          console.log(url);
        }
        xhr.open(method, url, true);
        if (method == "get") {
          xhr.send();
        } else {
          xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          xhr.send(data);
        }
        xhr.onreadystatechange = function () {
          if (xhr.readyState == 4) {
            if (xhr.status == 200) {
              if (success) {
                success(xhr.responseText);
        
              }
            } else {
              if (error) {
                error("Error" + xhr.status);
              }
            }
          }
        };
      }
      